<!DOCTYPE html>
<html>
<head>
    <title>四则运算</title>
</head>
<body>
    <input type="number" id="a">
    <input type="number" id="b">
    <button onclick="calculate()">计算</button>
    <p>加法结果: <span id="add"></span></p>
    <p>减法结果: <span id="sub"></span></p>
    <p>乘法结果: <span id="mul"></span></p>
    <p>除法结果: <span id="div"></span></p>

    <script>
        function calculate() {
            const a = parseFloat(document.getElementById('a').value);
            const b = parseFloat(document.getElementById('b').value);
            
            document.getElementById('add').innerText = a + b;
            document.getElementById('sub').innerText = a - b;
            document.getElementById('mul').innerText = a * b;
            document.getElementById('div').innerText = b !== 0 ? a / b : "不能除零";
        }
    </script>
</body>
</html>